#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/ioctl.h>


#define MAIN_BOARD     0x01
#define EXTERN_BOARD   0x02
#define ALL_LED_ON     _IO('A',0x01)
#define ALL_LED_OFF    _IO('A',0x02)
#define SEL_LED_ON     _IOW('S',0x01,unsigned int)
#define SEL_LED_OFF    _IOW('S',0x02,unsigned int)


int main(void)
{
	int fd;
	fd = open("/dev/led_drv", O_RDWR);
	if(fd < 0)
	{
		perror("open");
		exit(1);
	}

	while(1)
	{
		ioctl(fd, ALL_LED_ON);
		sleep(1);
		ioctl(fd, ALL_LED_OFF);
		sleep(1);
		ioctl(fd, SEL_LED_ON, MAIN_BOARD);
		sleep(1);
		ioctl(fd, SEL_LED_OFF, MAIN_BOARD);
		sleep(1);
		ioctl(fd, SEL_LED_ON, EXTERN_BOARD);
		sleep(1);
		ioctl(fd, SEL_LED_OFF, EXTERN_BOARD);
		sleep(1);
	}
	close(fd);
	return 0;
}
